<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>linsegr</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="linsegb.html" title="linsegb" />
    <link rel="next" href="locsend.html" title="locsend" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">linsegr</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="linsegb.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="locsend.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="linsegr"></a>
      <div class="titlepage"></div>
      <a id="IndexLinsegr" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">linsegr</span>
        </h2>
        <p>linsegr — 
      Trace a series of line segments between specified points including a release segment.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp119161456"></a>
        <h2>Description</h2>
        <p>
      Trace a series of line segments between specified points including a release segment.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp119235152"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>linsegr</strong></span> ia, idur1, ib [, idur2] [, ic] [...], irel, iz</pre>
        <pre class="synopsis">kres <span class="command"><strong>linsegr</strong></span> ia, idur1, ib [, idur2] [, ic] [...], irel, iz</pre>
      </div>
      <div class="refsect1">
        <a id="idp119238768"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ia</em></span> -- starting value.
    </p>
        <p>
      <span class="emphasis"><em>ib, ic</em></span>, etc. -- value after <span class="emphasis"><em>dur1</em></span> seconds, etc.
    </p>
        <p>
      <span class="emphasis"><em>idur1</em></span> -- duration in seconds of first segment. A zero or negative value will cause all initialization to be skipped.
    </p>
        <p>
      <span class="emphasis"><em>idur2, idur3</em></span>, etc. -- duration in seconds of subsequent segments. A zero or negative value will terminate the initialization process with the preceding point, permitting the last-defined line or curve to be continued indefinitely in performance. The default is zero.
    </p>
        <p>
      <span class="emphasis"><em>irel, iz</em></span> -- duration in seconds and final value of a note releasing segment.
    </p>
        <p>
      For Csound versions prior to 5.00, the release time cannot be longer than 32767/<a class="link" href="kr.html" title="kr"><em class="citetitle">kr</em></a> seconds. This limit has been extended to (2<sup>31</sup>-1)/kr.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp119247024"></a>
        <h2>Performance</h2>
        <p>
      These units generate control or audio signals whose values can pass through 2 or more specified points. The sum of <span class="emphasis"><em>dur</em></span> values may or may not equal the instrument's performance time: a shorter performance will truncate the specified pattern, while a longer one will cause the last-defined segment to continue on in the same direction.
    </p>
        <p>
      <span class="emphasis"><em>linsegr</em></span> is amongst the Csound <span class="quote">“<span class="quote">r</span>”</span> units that contain a note-off sensor and release time extender. When each senses an event termination or MIDI noteoff, it immediately extends the performance time of the current instrument by <span class="emphasis"><em>irel </em></span>seconds, and sets out to reach the value <span class="emphasis"><em>iz</em></span> by the end of that period (no matter which segment the unit is in). <span class="quote">“<span class="quote">r</span>”</span> units can also be modified by MIDI noteoff velocities. For two or more extenders in an instrument, extension is by the greatest period.
    </p>
        <p>
      You can use other pre-made envelopes which start a release segment upon recieving a note off message, like <a class="link" href="linenr.html" title="linenr"><em class="citetitle">linenr</em></a> and <a class="link" href="expsegr.html" title="expsegr"><em class="citetitle">expsegr</em></a>, or you can construct more complex envelopes using <a class="link" href="xtratim.html" title="xtratim"><em class="citetitle">xtratim</em></a> and <a class="link" href="release.html" title="release"><em class="citetitle">release</em></a>. Note that you don't need to use <a class="link" href="xtratim.html" title="xtratim"><em class="citetitle">xtratim</em></a> if you are using <span class="emphasis"><em>linsegr</em></span>, since the time is extended automatically.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp119258128"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the linsegr opcode. It uses the file <a class="ulink" href="examples/linsegr.csd" target="_top"><em class="citetitle">linsegr.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp119259984"></a>
          <p class="title">
            <strong>Example 426. Example of the linsegr opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac  -+rtmidi=virtual -M0   <span class="comment">;;;realtime audio out and realtime midi in</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o linsegr.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

<span class="oblock">instr</span> 1

	 	 
icps	<span class="opc">cpsmidi</span>	 	 
iamp	<span class="opc">ampmidi</span>	.3	 
 	 	 	 
kenv	<span class="opc">linsegr</span>	1, .05, 0.5, 1, 0
asig	<span class="opc">pluck</span>	kenv, icps, 200, 1, 1	 
	<span class="opc">outs</span>	asig, asig
	 
<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span> 1 0 4096 10 1	<span class="comment">;sine wave</span>

<span class="stamnt">f</span>0 30	<span class="comment">;runs 30 seconds</span>
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp119264272"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="linenr.html" title="linenr"><em class="citetitle">linenr</em></a>,
      <a class="link" href="expsegr.html" title="expsegr"><em class="citetitle">expsegr</em></a>,
      <a class="link" href="envlpxr.html" title="envlpxr"><em class="citetitle">envlpxr</em></a>,
      <a class="link" href="mxadsr.html" title="mxadsr"><em class="citetitle">mxadsr</em></a>,
      <a class="link" href="madsr.html" title="madsr"><em class="citetitle">madsr</em></a>
      <a class="link" href="expon.html" title="expon"><em class="citetitle">expon</em></a>,
      <a class="link" href="expseg.html" title="expseg"><em class="citetitle">expseg</em></a>,
      <a class="link" href="expsega.html" title="expsega"><em class="citetitle">expsega</em></a>
      <a class="link" href="line.html" title="line"><em class="citetitle">line</em></a>,
      <a class="link" href="linseg.html" title="linseg"><em class="citetitle">linseg</em></a>,
      <a class="link" href="xtratim.html" title="xtratim"><em class="citetitle">xtratim</em></a>,
      <a class="link" href="transegr.html" title="transegr"><em class="citetitle">transegr</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp119276880"></a>
        <h2>Credits</h2>
        <p>Author: Barry L. Vercoe</p>
        <p>December 2002, December 2006. Thanks to Istvan Varga, added documentation about the maximum release time.</p>
        <p>New in Csound 3.47</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="linsegb.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="locsend.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">linsegb </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> locsend</td>
        </tr>
      </table>
    </div>
  </body>
</html>
